package com.zqx.visitor.concretevisitor;

import com.zqx.visitor.abstractvisitor.Department;
import com.zqx.visitor.concreteelement.FulltimeEmployee;
import com.zqx.visitor.concreteelement.ParttimeEmployee;
import lombok.extern.slf4j.Slf4j;

/**
 * description: 具体访问者类
 * @author zqx
 * @date 2018/09/04
 */
@Slf4j
public class FADepartment extends Department {

    //实现财务部对全职员工的访问
    @Override
    public void visit(FulltimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double weeklyWage = employee.getWeeklyWage();
        //计算超过时长
        if(workTime > 40){
            weeklyWage = weeklyWage + (workTime-40)*100;
        }//计算不足时长
        else if(workTime < 40){
            weeklyWage = weeklyWage-(40 - workTime)*80;
            if(weeklyWage < 0){
                weeklyWage = 0;
            }
        }
        log.info("【正式员工】"+employee.getName()+"实际工资为："+weeklyWage +"元。");
    }

    //实现财务部对临时工的访问
    @Override
    public void visit(ParttimeEmployee employee) {
        int workTime = employee.getWorkTime();
        double hourWage = employee.getHourWage();
        log.info("【临时工】"+employee.getName()+"实际工资为："+workTime*hourWage+"元。");
    }
}
